package com.ice.work.moment.facade.ticket.controller.fallback;

import com.honeybee.cloud.framework.base.exception.service.ServiceExceptionBase;
import com.honeybee.cloud.framework.base.exception.service.ServiceExceptionEnum;
import com.honeybee.cloud.framework.common.response.ResponseEntity;
import com.ice.work.moment.facade.ticket.controller.ITicketController;
import com.ice.work.moment.facade.ticket.dto.CarDTO;
import com.ice.work.moment.facade.ticket.request.QueryTicketRequest;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @Description 回退
 * @Author DELL
 * @Create 2018-12-10
 * @Since 1.0.0
 */
@Slf4j
@SuppressWarnings("all")
public abstract class TicketHystrixFallbackFactory implements FallbackFactory<ITicketController> {
    @Override
    public ITicketController create(Throwable throwable) {
        log.error("服务调用异常", throwable);
        return new ITicketController() {
            @Override
            public ResponseEntity<List<CarDTO>> queryTicket(QueryTicketRequest request, String appKey) {
                return getInstance();
            }

        };
    }
    protected ResponseEntity getInstance() {
        return ResponseEntity.error(ServiceExceptionBase.getInstance(ServiceExceptionEnum.MOMENT_TICKET_SERVICE));
    }
}
